package com.uyaer.card.engine.tick
{
	internal class TimerPool
	{
		private static var timers:Vector.<UTimer> = new Vector.<UTimer>();
		/**
		 *获得一个timer对象 
		 * @param delay
		 * @param repeat
		 * @return 
		 * 
		 */		
		public static function getOne(delay:int,repeat:int):UTimer{
			var timer:UTimer = null;
			if(timers.length>0){
				timer = timers.pop();
				timer.delay = delay;
				timer.repeatCount = repeat; 
			}else{
				timer = new UTimer(delay,repeat);				
			}
			return timer;
		}
		
		/**
		 *回收一个timer 
		 * @param timer
		 * 
		 */		
		public static function recycle(timer:UTimer):void{
			if(timer){
				timer.stop();
				timer.reset();
				timers.push(timer);
			}
		}
	}
}